/**
 * @description 将字符串转为正则表达式
 * @param {字符} str
 * @returns
 */
const getRegFromString = (str: string) => {
	const arr: string[] = str.split('/');
	const modifiers = arr.pop();
	const pattern = arr.join('');//将数组转为字符串
	arr.shift();
	return new RegExp(pattern, modifiers);
};
// 使用
// const str = '/^1[3,4,5,6,7,8,9][0-9]{9}$/';
// const re = getRegFromString(str)
// const mobile = 13890583474
// const result = re.test(mobile);
// console.log(result)
export default getRegFromString;